#include "feiwu.h"
#include "ui_feiwu.h"

FeiWu::FeiWu(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::FeiWu)
{
    ui->setupUi(this);
    ini();
}

FeiWu::~FeiWu()
{
    delete ui;
}

void FeiWu::ini()
{
    QString fileName;
    fileName = QCoreApplication::applicationDirPath();
    fileName+="/Settings/set.ini";
    QSettings settings(fileName, QSettings::IniFormat);

    bool exist = settings.contains("set/feiwu_number");
    if(exist == true)
    {
        number = settings.value("set/feiwu_number").toInt();
        ui->label_number->setText("废物天数：" + QString::number(number));
    }
    else
    {
        settings.setValue("set/feiwu_number", number);
        ui->label_number->setText("废物天数：" + QString::number(number));
    }
}


void FeiWu::on_pushButton_yes_clicked()
{
    QString fileName;
    fileName = QCoreApplication::applicationDirPath();
    fileName+="/Settings/set.ini";
    QSettings settings(fileName, QSettings::IniFormat);

    number++;
    settings.setValue("set/feiwu_number", number);
    ui->label_number->setText("废物天数：" + QString::number(number));
}


void FeiWu::on_pushButton_no_clicked()
{
    QString fileName;
    fileName = QCoreApplication::applicationDirPath();
    fileName+="/Settings/set.ini";
    QSettings settings(fileName, QSettings::IniFormat);

    number--;
    settings.setValue("set/feiwu_number", number);
    ui->label_number->setText("废物天数：" + QString::number(number));
}

